//
//  UBEncryptTool.m
//  UB_UBuddy
//
//  Created by ponta on 16/3/16.
//  Copyright © 2016年 UB. All rights reserved.
//

#import "UBEncryptTool.h"
#import "NSString+Hash.h"


@implementation UBEncryptTool


/**
 *  MD5($pass.$salt)
 *
 *  @param text 明文
 *
 *  @return 加密后的密文
 */
+ (NSString *)MD5Salt:(NSString *)text
{
    // 撒盐：随机地往明文中插入任意字符串
    NSString *salt = [text stringByAppendingString:@"datouemc"];
    return [salt md5String];
}

/**
 *  MD5(MD5($pass))
 *
 *  @param text 明文
 *
 *  @return 加密后的密文
 */
+ (NSString *)doubleMD5:(NSString *)text
{
    return [[text md5String] md5String];
}

/**
 *  先加密，后乱序
 *
 *  @param text 明文
 *
 *  @return 加密后的密文
 */
+ (NSString *)MD5Reorder:(NSString *)text
{
    text = [text stringByAppendingString:@"datouemc"];

    NSString *pwd = [text md5String];
    
    NSString *prefix = [pwd substringFromIndex:6];
    NSString *subfix = [pwd substringToIndex:6];
    
    NSString *result = [prefix stringByAppendingString:subfix];
    
    //    NSLog(@"0000000000000============%@",result);
    
    return result;
}



@end
